import {formatSecond} from '../../utils/date';
import collectFormId from '../../behaviors/collect-formid';
Component({
    behaviors: [collectFormId],
    /**
   * 组件的属性列表
   */
    properties: {
        title: {
            type: String
        },
        duration: {
            type: Number,
            observer (newVal, oldVal) {
                this.setData({
                    durationFormated: formatSecond(newVal, true)
                });
            }
        },
        showDuration: {
            type: Boolean,
            default: false
        }, // 是否显示音频时长
        chapterNum: {
            type: Number
        },
        chapterTotalNum: {
            type: Number
        }, // 课程总章节数
        isPlaying: {
            type: Boolean,
            default: false
        }, // 正在播放
        isPlayable: {
            type: Boolean,
            default: false
        }, // 可播放
        isNew: {
            type: Boolean,
            default: false
        }, // 最近更新
        isTrial: {
            type: Boolean,
            default: false
        }, // 试用
        isPublished: {
            type: Boolean,
            default: false
        }, // 待更新
        isLatestPlayed: {
            type: Boolean,
            default: false
        }, // 上次播放
        showChapterNum: {
            type: Boolean,
            default: false
        },
        showUpdateDate: {
            type: Boolean,
            default: false
        },
        updateDate: {
            type: String,
            default: ''
        }, // 订阅的更新日期
        hasAudio: {
            type: Boolean,
            default: false
        }, // 是否有音频
        data: {
            type: Object,
            default: null
        }
    },

    /**
   * 组件的初始数据
   */
    data: {
        durationFormated: ''
    },

    /**
   * 组件的方法列表
   */
    methods: {
        onItemTapped () {
            this.triggerEvent('itemtap', this.properties.data);
        }
    }
});
